Ext.onReady(function(){
	//使用表单提示
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget ="side";
	//定义一个输入表单
	var simple = new Ext.FormPanel({
		labelWidth:40,
		baseCls:'x-plain',
		defaults:{width:180},
		items:[{
			xtype:'textfield',
			fieldLabel:'账号',
			name:'user.username',
			allowBlank:false,
			blankText:'账号不能为空'
		},{
			xtype:'textfield',
			inputType:"password",
			fieldLabel:"密码",
			name:'user.password',
			allowBlank:false,
			blankText:"密码不能为空"
		}],
		buttons:[{
			text:"提交",
			type:"submit",
			handler:function(){
				if(simple.form.isValid()){
					Ext.MessageBox.show({
						title:"请等待",
						msg:"正在加载",
						progressText:"",
						width:300,
						progress:true,
						closable:false,
						animEl:'loding'
					});
					
					var f = function(v){
						return function(){
							var i = v/11;
							Ext.MessageBox.updateProgress(i,'');
						}
					}
					
					for(var i = 1; i < 13; i++){
						setTimeout(f(i),i * 150);
					}
					
					//提交到服务器操作
					simple.form.doAction("submit",{
						url:"Login.action",
						method:"post",
						success:function(form,action){
							document.location = 'index.jsp';
							Ext.Msg.alert("登录成功！",action.result.message);
						},
						failure:function(form, action){
							Ext.Msg.alert('登录失败',action.result.message);
						}
						
					});
				}
			}
			},{
				text:"重置",
				handler:function(){
					//重置表单
					simple.form.reset();
				}
			}]
	});
	//定义窗体
	var _window = new Ext.Window({
		title:"登录窗口",
		layout:"fit",
		width:280,
		height:150,
		plain:true,
		bodyStyle:"padding:10px",
		maximizable:false,
		closeAction:"close",
		closable:false,
		collapsible:true,
		plain:true,
		buttonAlign:"center",
		items:simple
	});
	_window.show();
});
